﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace RiotTweet
{
    public class MainFormAction
    {
        public void SendDirectMessage(TwitterAccess twitter, string user)
        {
            DirectMessageForm form = new DirectMessageForm();
            form.userNameItem.Text = user;
            
            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string sendUser = form.userNameItem.Text;
            string message = form.messageItem.Text;

            try
            {
                twitter.PostDirectMessage(sendUser, message);
            }
            catch (WebException we)
            {
                AppUtil.ErrorLog("dm送信失敗", we);
                AppUtil.ShowError("DMの送信に失敗しました。");
            }
        }
    }
}
